*  FILE NAME: INPDRUG.PRG
*  BY: NURJADI PURNAMA
*  DATE: March 26, 1996
*  DESC:
*  CALLED BY:
*  DATA FILES:

set cent on

SET PROC TO SOSPRO
SET PROC TO BOXPROC
STORE ' ' TO AEANAME,AEAADDR,AEACITY,AEACOUN,AEACURR
STORE .F. TO AEAHEAL,AEADECI
DO START

set function 10 to space(3)
dr='n:'
f1='EXRATE'
F2='AEACORP'

SELE 1
set exclu off
use &dr&f1 index &dr&f1
SELE 2
set exclu off
use &dr&f2

SELE 1
go bottom
set colo to bg+/b,w+/n
CLEAR
@ 7, 1 CLEA TO 23,78
do addressa
SET COLO TO BG+/B,W+/N
@ 4,1 CLEAR TO 6,50
DO BOXT WITH 4,3,"BASE CURRENCY CODE ENTRY",'BG+','GR',.F.,.T.
SET COLO TO BG+/B,W+/N
set inte off
@ 08, 5 say 'BASE CURRENCY CODE  :'
@ 10, 5 say 'BASE CURRENCY NAME  :'
@ 12, 5 say 'OTHER CURRENCY CODE :'
@ 14, 5 say 'OTHER CURRENCY NAME :'
@ 16, 5 say 'RATE                :'
@ 18, 5 say 'OPERATOR            :'
set color to w
del_rec = 'N'
option = 1
record_no = recno()
do while option < 5
   SELE 1
   set deli off

   cBcode    = BASE_CODE
   cBname    = BASE_NAME
   cOcode    = OTHER_CODE
   cOname    = OTHER_NAME
   nRate     = RATE
   cOper     = OPERATOR
   @ 08,27 say cBcode
   @ 10,27 say cBname
   @ 12,27 say cOcode
   @ 14,27 say cOname
*   @ 16,27 say nRate PICT '#,###,##9.99'
   DO SAYG WITH 16,27,nrate,'9,999,999.99','999,999,999'
   @ 18,27 say cOper
   do mn_formb
   do case
   case option = 1
      do while .T.
         goto record_no
         cBcode   = spac(3)
         cBname   = spac(15)
         cOcode   = spac(3)
         cOname   = spac(15)
         nRate    = 0
         cOper    = spac(1)
         @ 08,27 say cBcode
         @ 10,27 say cBname
         @ 12,27 say cOcode
         @ 14,27 say cOname
*         @ 16,27 say nRate PICT '#,###,##9.99'
         DO SAYG WITH 16,27,nrate,'9,999,999.99','999,999,999'
         @ 18,27 say cOper

         ply=savescreen(12,45,17,65)
         GO TOP
         CNT=0
         count to cnt
         spes='Y'
         DO WHILE spes='Y'
            GO TOP
            if cnt>0
               set colo to bg+/gr+,w+/n
               DECLARE FILD[CNT]
               declare nore[cnt]
               DECLARE anam[CNT]
               declare acod[cnt]
               STOR 0 TO CR
               DO WHILE .NOT. EOF()
                  set colo to bg+/gr+,w+/n
                  CR=cr+1
                  fild[cr]=' '+other_code+' '+other_name
                  nore[cr]=recno()
                  acod[cr]=other_code
                  anam[CR]=other_name

                  skip
               enddo
               SET COLO TO BG+/gr+,W+/N
               inkey()
               CARI=achoice(12,45,17,65,FILD)
               mix=lastkey()
               DO CASE
                  CASE MIX=13
                     SPES='Y'
                     record_no = nore[CARI]
                     cOcode    = acod[CARI]
                     cOname    = anam[cari]
                     EXIT
                  case mix=27
                     SPES='N'
               ENDCASE
            ELSE
               EXIT
            ENDIF
         ENDDO
         SET COLOR TO BG+/B, W+/N
         restscreen(12,45,17,65,ply)
         if spes='Y'
            GO RECORD_NO
            @ 12,27 say cOcode
            @ 14,27 say cOname
         endif

         if m->cOcode=space(3)
            exit
         endif
         EXIT
      enddo
   case option = 2
      SET DELI OFF
      SET INTE ON
      nRate = RATE
      cOper = OPERATOR
*      @ 16,27 get nRate PICT '#,###,##9.99'
      DO GETS WITH 16,27,nrate,'9,999,999.99','999,999,999'
      READ
* ****************************************************
* Thien added on 06 Aug 2010 to bypass Operator entry*
* ****************************************************
*      DO WHIL .T.
*         @ 18,27 get cOper
*         read
*         IF cOper $ '/*'
*            EXIT
*         ENDI
*      ENDD
      LAYAR=SAVESCREEN(0,0,24,79)
      choice = ' '
      do get_optn with 'SAVE (Y/N)','YN',choice
      if choice = 'Y'
         if rec_lock()
            repl RATE     with nRate
*            repl OPERATOR with cOper
* End Thien - 06 Aug 2010
* ******************************************************           
         endif
         unlock
      endif
      RESTSCREEN(0,0,24,79,LAYAR)
   case option = 3
      DO WHIL .T.
         SELE 2
         cBcode = COMP_CURR
         cBname = COMP_CUNM

         SELE 1
         cOcode = SPAC(3)
         cOname = SPAC(15)
         nRate  = 0
         cOper  = SPAC(1)

         @ 08,27 say cBcode
         @ 10,27 say cBname
         @ 12,27 say cOcode
         @ 14,27 say cOname
*         @ 16,27 say nRate PICT '#,###,##9.99'
         DO SAYG WITH 16,27,nrate,'9,999,999.99','999,999,999'
         @ 18,27 say cOper

         @ 12,27 GET cOcode PICT '@!'
         READ
         IF LASTKEY() = 27 .OR. cOcode = SPAC(3)
            EXIT
         ENDI

         SEEK cOcode
         IF .NOT. EOF()
            lyr=savescreen(0,0,24,79)
            do disp_msg with 'Code already exist'
            restscreen(0,0,24,79,lyr)
            LOOP
         ENDI

         @ 14,27 GET cOname
*         @ 16,27 GET nRate  PICT '#,###,##9.99'
         DO GETS WITH 16,27,nrate,'9,999,999.99','999,999,999'
         READ
         DO WHIL .T.
            @ 18,27 GET cOper
            READ
            IF cOper $ '/*'
               EXIT
            ENDI
         ENDD

         choice = 'Y'
         LYRR = SAVESCREEN(0,0,24,79)
         do get_optn with 'SAVE (Y/N)','YN',choice
         if choice = 'Y'
            IF FIL_LOCK()
               append blank
            ENDIF
            IF REC_LOCK()
               REPL BASE_CODE WITH cBcode, BASE_NAME WITH cBname, OTHER_CODE;
                  WITH cOcode, OTHER_NAME WITH cOname, RATE WITH nRate,;
                  OPERATOR WITH cOper
            ENDIF
            UNLOCK
         else
            goto bott
         endif
         RESTSCREEN(0,0,24,79,LYRR)
      ENDD
      loop

      SET COLO TO B/B

      @ 6,50 clea to 6,75
      option = ' '
   case option = 4
      choice = ' '
      do get_optn with 'Delete (Y/N)','YN',choice
      if choice = 'Y'
         IF REC_LOCK()
            delete
         ENDIF
         UNLOCK
         del_rec = 'Y'
         go bottom
      endif
   endcase
enddo
if del_rec='Y'
   IF NET_USE("&DR&F1",.T.,'1',10)
      PACK
   ENDIF
endif
close index
close data
set inte on
SET COLO TO W/N,W/N
CLEA
return
*Formatted by: Herman T Ver. 7.1  on March 26, 1996.
